package br.ucb.sigplan.action.impl;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.ucb.sigplan.action.Action;
import br.ucb.sigplan.crud.ConteudoCrud;
import br.ucb.sigplan.exception.DAOException;

public class ExcluirConteudoAction implements Action {

	@Override
	public String execute(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		Integer idConteudo = new Integer(req.getParameter("idConteudo"));
		String msg = null;
		try {
			ConteudoCrud.delete(idConteudo);
		} catch (DAOException e) {
			msg = e.getMessage();
			System.out.println("Erro = "+e.getMessage());
		}
		if (msg == null) {
			msg = "conteudoSucesso";
		}
		req.setAttribute("msg",msg);
		return "abrirListarConteudo.do";
	}

}
